package cn.tedu.lbs.basic.web.util;

import com.tarena.lbs.common.passport.principle.UserPrinciple;

public class AuthenticationContextUtil {
    //存储 当前线程 和业务数据的ThreadLocal对象
    private static ThreadLocal<UserPrinciple> REGISTER=new ThreadLocal<>();

    //需要工具提供存储功能
    public static void save(UserPrinciple value){
        Thread.currentThread();
        REGISTER.set(value);
    }
    //需要工具提供读取功能
    public static UserPrinciple get(){
        Thread.currentThread();
        return REGISTER.get();
    }
    //需要工具提供清除功能[重点]
    public static void clear(){
        //只清空当前线程曾经存储的过程value
        REGISTER.remove();
    }
}
